package com.jysz.certificate.persistence.model.pm;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.jysz.certificate.persistence.enums.PerformanceAssignStatus;
import com.jysz.certificate.persistence.model.system.User;
import com.jysz.webcore.ssh.entity.AbstractBaseEntity;

/**
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 *
 */
@Entity
@Table(name = "pm_performance_assign_")
@org.hibernate.annotations.Entity
public class PerformanceAssign extends AbstractBaseEntity<Long>  {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private double payinAmount; //实收金额
	private double totalAmount; //绩效总额
	private double areaTotalAmount;//区域经理绩效总额
	
	private PerformanceAssignStatus status;
	
	private Date confirmDate;//确认时间
	private String monthDate;//绩效月份
	private Date confirmPlanDate;//预订计划绩效最后确认时间。
	
	private List<PerformanceAssignShopDetail> performanceAssignShopDetails;
	
	private List<PmUser> pmUsers; //系统生成人员名单。
	
	private List<UserPerformance> userPerformances;
	
	private User releaseConfirmUser;
	private User confirmAssignUser;
	private User pmConfirmUser;
	private Date releaseConfirmDate;
	private Date confirmAssignDate;
	private Date pmConfirmDate;
	
	@Column(name = "_confirmDate")
	public Date getConfirmDate() {
		return confirmDate;
	}	
	
	@Column(name = "_monthDate", length = 7)
	public String getMonthDate() {
		return monthDate;
	}
	
	@Column(name = "_confirmPlanDate")
	public Date getConfirmPlanDate() {
		return confirmPlanDate;
	}
	
	@Column(name = "_status")
	@Enumerated(EnumType.ORDINAL)
	public PerformanceAssignStatus getStatus() {
		return status;
	}
	
	@Column(name = "_totalAmount")
	public double getTotalAmount() {
		return totalAmount;
	}
	
	@Column(name = "_payinAmount")
	public double getPayinAmount() {
		return payinAmount;
	}
	
	public void setPayinAmount(double payinAmount) {
		this.payinAmount = payinAmount;
	}

	public void setTotalAmount(double totalAmount) {
		this.totalAmount = totalAmount;
	}

	public void setMonthDate(String monthDate) {
		this.monthDate = monthDate;
	}

	public void setConfirmPlanDate(Date confirmPlanDate) {
		this.confirmPlanDate = confirmPlanDate;
	}

	public void setStatus(PerformanceAssignStatus status) {
		this.status = status;
	}

	public void setConfirmDate(Date confirmDate) {
		this.confirmDate = confirmDate;
	}

	@OneToMany(targetEntity = PerformanceAssignShopDetail.class, cascade = { CascadeType.ALL }, mappedBy = "performanceAssign")  
	public List<PerformanceAssignShopDetail> getPerformanceAssignShopDetails() {
		return performanceAssignShopDetails;
	}

	public void setPerformanceAssignShopDetails(
			List<PerformanceAssignShopDetail> performanceAssignShopDetails) {
		this.performanceAssignShopDetails = performanceAssignShopDetails;
	}

	@OneToMany(targetEntity = PmUser.class, cascade = { CascadeType.ALL }, mappedBy = "performanceAssign") 
	public List<PmUser> getPmUsers() {
		return pmUsers;
	}

	public void setPmUsers(List<PmUser> pmUsers) {
		this.pmUsers = pmUsers;
	}
	
	@Column(name = "_area_totalamount")
	public Double getAreaTotalAmount() {
		return areaTotalAmount;
	}

	public void setAreaTotalAmount(double areaTotalAmount) {
		this.areaTotalAmount = areaTotalAmount;
	}

	@OneToMany(targetEntity = UserPerformance.class, cascade = {CascadeType.PERSIST })
	@JoinColumn(name="_performance_assign_id")
	public List<UserPerformance> getUserPerformances() {
		return userPerformances;
	}

	public void setUserPerformances(List<UserPerformance> userPerformances) {
		this.userPerformances = userPerformances;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_release_confirm_user")
	public User getReleaseConfirmUser() {
		return releaseConfirmUser;
	}

	public void setReleaseConfirmUser(User releaseConfirmUser) {
		this.releaseConfirmUser = releaseConfirmUser;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_confirm_assign_user")
	public User getConfirmAssignUser() {
		return confirmAssignUser;
	}

	public void setConfirmAssignUser(User confirmAssignUser) {
		this.confirmAssignUser = confirmAssignUser;
	}

	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_pm_confirm_user")
	public User getPmConfirmUser() {
		return pmConfirmUser;
	}

	public void setPmConfirmUser(User pmConfirmUser) {
		this.pmConfirmUser = pmConfirmUser;
	}

	@Column(name = "_release_confirm_date")
	public Date getReleaseConfirmDate() {
		return releaseConfirmDate;
	}

	public void setReleaseConfirmDate(Date releaseConfirmDate) {
		this.releaseConfirmDate = releaseConfirmDate;
	}

	@Column(name = "_confirm_assign_date")
	public Date getConfirmAssignDate() {
		return confirmAssignDate;
	}

	public void setConfirmAssignDate(Date confirmAssignDate) {
		this.confirmAssignDate = confirmAssignDate;
	}

	@Column(name = "pm_confirm_date")
	public Date getPmConfirmDate() {
		return pmConfirmDate;
	}

	public void setPmConfirmDate(Date pmConfirmDate) {
		this.pmConfirmDate = pmConfirmDate;
	}
	
	
}
